package com.java110.mall.goods.smo.impl;


import com.java110.dto.housekeeping.HousekeepingResourceDto;
import com.java110.intf.goods.IHousekeepingResourceInnerServiceSMO;
import com.java110.mall.goods.dao.IHousekeepingResourceServiceDao;
import com.java110.po.housekeeping.HousekeepingResourcePo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 家政服务类型内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class HousekeepingResourceInnerServiceSMOImpl extends BaseServiceSMO implements IHousekeepingResourceInnerServiceSMO {

    @Autowired
    private IHousekeepingResourceServiceDao housekeepingResourceServiceDaoImpl;


    @Override
    public int saveHousekeepingResource(@RequestBody HousekeepingResourcePo housekeepingResourcePo) {
        int saveFlag = 1;
        housekeepingResourceServiceDaoImpl.saveHousekeepingResourceInfo(BeanConvertUtil.beanCovertMap(housekeepingResourcePo));
        return saveFlag;
    }

     @Override
    public int updateHousekeepingResource(@RequestBody  HousekeepingResourcePo housekeepingResourcePo) {
        int saveFlag = 1;
         housekeepingResourceServiceDaoImpl.updateHousekeepingResourceInfo(BeanConvertUtil.beanCovertMap(housekeepingResourcePo));
        return saveFlag;
    }

     @Override
    public int deleteHousekeepingResource(@RequestBody  HousekeepingResourcePo housekeepingResourcePo) {
        int saveFlag = 1;
        housekeepingResourcePo.setStatusCd("1");
        housekeepingResourceServiceDaoImpl.updateHousekeepingResourceInfo(BeanConvertUtil.beanCovertMap(housekeepingResourcePo));
        return saveFlag;
    }

    @Override
    public List<HousekeepingResourceDto> queryHousekeepingResources(@RequestBody  HousekeepingResourceDto housekeepingResourceDto) {

        //校验是否传了 分页信息

        int page = housekeepingResourceDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingResourceDto.setPage((page - 1) * housekeepingResourceDto.getRow());
        }

        List<HousekeepingResourceDto> housekeepingResources = BeanConvertUtil.covertBeanList(housekeepingResourceServiceDaoImpl.getHousekeepingResourceInfo(BeanConvertUtil.beanCovertMap(housekeepingResourceDto)), HousekeepingResourceDto.class);

        return housekeepingResources;
    }


    @Override
    public int queryHousekeepingResourcesCount(@RequestBody HousekeepingResourceDto housekeepingResourceDto) {
        return housekeepingResourceServiceDaoImpl.queryHousekeepingResourcesCount(BeanConvertUtil.beanCovertMap(housekeepingResourceDto));    }

    public IHousekeepingResourceServiceDao getHousekeepingResourceServiceDaoImpl() {
        return housekeepingResourceServiceDaoImpl;
    }

    public void setHousekeepingResourceServiceDaoImpl(IHousekeepingResourceServiceDao housekeepingResourceServiceDaoImpl) {
        this.housekeepingResourceServiceDaoImpl = housekeepingResourceServiceDaoImpl;
    }
}
